package designpattern.flyweight.news;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class NewsFactory {

    private static final Map<String,INews> newsPool = new ConcurrentHashMap<>();

    public static INews getNews(NewsInfo newsInfo){
        if (!newsPool.containsKey(newsInfo.getId())){
            INews news = new NewsImpl();
            newsPool.put(newsInfo.getId(),news);
        }
        return newsPool.get(newsInfo.getId());
    }
}
